<?php


namespace app\adminapi\lists\user;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\user\Userlog;
use app\common\lists\ListsSearchInterface;


/**
 * portal认证记录列表
 * Class UserlogLists
 * @package app\adminapi\listsuser
 */
class UserlogLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public function setSearch(): array
    {
        return [
            '%like%' => ['pid', 'openid', 'phone'],
        ];
    }


    /**
     * @notes 获取portal认证记录列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public function lists(): array
    {
        return Userlog::where($this->searchWhere)
            ->field(['id', 'pid', 'openid', 'phone', 'content', 'create_time'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order(['id' => 'desc'])
            ->select()
            ->toArray();
    }


    /**
     * @notes 获取portal认证记录数量
     * @return int
     * @author gzx
     * @date 2024/07/04 16:31
     */
    public function count(): int
    {
        return Userlog::where($this->searchWhere)->count();
    }

}